package com.dgw.springbootstronger.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @program: springboot-stronger
 * @description:
 * @author: Mr.Dai
 * @create: 2020-03-01 15:53
 **/
@Component
@Aspect
public class DonoTimeAspects {

    @Pointcut("@annotation(com.dgw.springbootstronger.annotation.DonoTime)")
    public void pointCut(){

    }

    @Around("pointCut()")
    public Object  around(ProceedingJoinPoint joinPoint){
        System.out.println("方法开始时间是:"+new Date());
        Object o = null;
        try {
            o = joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("方法结束时间是:"+new Date()) ;
        return o;
    }
}
